﻿// RegKeyEx.cs
// Aleksei Vassiljev
// {4DC17B88-5237-4e95-A60D-72988F554D4F}

using Microsoft.Win32;

namespace OracleTools.Core
{
    /// <summary>
    /// Constants and UpdateValue methods
    /// </summary>
    public class RegKeyEx
    {
        public const string ORACLE_HOME = "ORACLE_HOME";
        public const string ORACLE_HOME_KEY = "ORACLE_HOME_KEY";
        public const string ORACLE_HOME_NAME = "ORACLE_HOME_NAME";
        public const string ORACLE_GROUP_NAME = "ORACLE_GROUP_NAME";
        public const string ORACLE_BUNDLE_NAME = "ORACLE_BUNDLE_NAME";
        public const string NLS_LANG = "NLS_LANG";
        public const string OLEDB = "OLEDB";
        public const string VOBHOME20 = "VOBHOME2.0";
        public const string OO4O = "OO4O";

        /// <summary>
        /// OraOLEDB 1.0 Type Library - file OraOLEDBXX.dll  
        /// {0BB9AFD1-51A1-11D2-BB7D-00C04FA30080}
        /// </summary>
        public const string TYPELIB_ORAOLEDB_1_0_GUID = "{0BB9AFD1-51A1-11D2-BB7D-00C04FA30080}";
        /// <summary>
        /// Oracle Data Control - file oradc.ocx  
        /// {92096210-97DF-11CF-9F27-02608C4BF3B5}
        /// </summary>
        public const string TYPELIB_ORACLE_DATA_CONTROL_GUID = "{92096210-97DF-11CF-9F27-02608C4BF3B5}";
        /// <summary>
        /// Oracle InProc Server Type Library, 
        /// Version 4.0 for 9i, 5.0 for 10g and 11g  
        /// {F2D4ED20-FFD3-101A-ADF2-04021C007002}
        /// </summary>
        public const string TYPELIB_ORACLE_INPROC_SERVER_GUID = "{F2D4ED20-FFD3-101A-ADF2-04021C007002}";
        
        /// <summary>
        /// Oracle Objects For OLE - OracleInProcServer.XOraSession, has path to oipXX.dll  
        /// {3893B4A0-FFD8-101A-ADF2-04021C007002}
        /// </summary>
        public const string CLSID_XORASESSION_GUID = "{3893B4A0-FFD8-101A-ADF2-04021C007002}";

        /// <summary>
        /// OraOLEDB.Oracle, has path to OraOLEDB11.DLL  
        /// {3F63C36E-51A3-11D2-BB7D-00C04FA30080}
        /// </summary>
        public const string CLSID_ORAOLEDB_GUID = "{3F63C36E-51A3-11D2-BB7D-00C04FA30080}";

        /// <summary>
        /// OraOLEDB.ErrorLookup, has path to OraOLEDB11.DLL  
        /// {3FC8E6E4-53FF-11D2-BB7D-00C04FA30080}
        /// </summary>
        public const string CLSID_ORAOLEDB_ERROR_LOOKUP_GUID = "{3FC8E6E4-53FF-11D2-BB7D-00C04FA30080}";

        /// <summary>
        /// OracleInProcServer.XOraServer, has path to oip11.dll  
        /// {5CEA8296-F9B9-11D1-9E07-00C04FC2BED8}
        /// </summary>
        public const string CLSID_XORASERVER_GUID = "{5CEA8296-F9B9-11D1-9E07-00C04FC2BED8}";


        private RegKeyEx() { }

        private static RegKeyEx m_this = null;
        public static RegKeyEx getInstance()
        {
            return (m_this == null) ? new RegKeyEx() : m_this;
        }

        public void UpdateValue(RegistryKey key, string name, object value, RegistryValueKind valueKind = RegistryValueKind.String)
        {
            if(key != null)
                if (key.GetValue(name) != null)
                {
                    key.SetValue(name, value, valueKind);
                    LogWriter.LogLine("{0}:{1} = {2}", key, name, value);
                }
        }


        
    }
}
